#ifndef __MAIN_H
#define __MAIN_H

#include "stm32f10x.h"                  // Device header
#include "buzzer.h"
#include "eeprom.h"
#include "delay.h"
#include "rc522.h"
#include "timer.h"
#include "usart.h"
#include "dht11.h"
#include "gpio.h"
#include "scan.h"
#include "iwdg.h"
#include "sys.h"

#define SDATA_HEAD      0x4c
#define SDATA_HEAD_BIT  0X00
#define SDATA_TYPE_BIT  0X01
//#define SDATA_SIZE_BIT  0X02  暂不需要
#define SDATA_START_BIT 0x02

#define HEARTBEAT_MAX   7200

#define LASER_PIN   GPIO_Pin_8
#define LASER_PORT  GPIOA
#define LASER_CLK   RCC_APB2Periph_GPIOA

#define LED_PIN     GPIO_Pin_11
#define LED_PORT    GPIOA
#define LED_CLK     RCC_APB2Periph_GPIOA

#define LED_ON  GPIO_ResetBits(LED_PORT, LED_PIN)
#define LED_OFF GPIO_SetBits(LED_PORT, LED_PIN)

#define Interval    2  //间隔时间s
#define CLEAR   0
#define PUSH    1

#define DP9_PORT    GPIOB
#define DP9_CLK     RCC_APB2Periph_GPIOB

#define DP9_P1  //485a
#define DP9_P2  //485b
#define DP9_P3  GPIO_Pin_13 //TMI1_CH1
#define DP9_P4  GPIO_Pin_1  //ADC1_IN9
#define DP9_P5  //GND
#define DP9_P6  GPIO_Pin_15 //TMI1_CH3
#define DP9_P7  GPIO_Pin_14 //TMI1_CH2
#define DP9_P8  GPIO_Pin_12
#define DP9_P9  GPIO_Pin_0  //ADC1_IN8

typedef struct
{
    uint16_t heartbeat;
    uint8_t rfid, dht11;
} act_timer_t;    //行动计时器

typedef struct
{
    uint16_t temp;
    uint16_t humi;
} dht11_data_t;    //温湿度数据

typedef struct
{
    union
    {
        uint8_t     array[2];
        uint16_t    data;
    } tag_type;  //标签类型
    union
    {
        uint8_t     array[4];
        uint32_t    data;
    } sn_code;  //sn码
    uint32_t sn_now;
} rfid_info_t;    //ic卡信息

#endif
